package com.zjb.accountManager.controllers;

import com.jfinal.core.Controller;
import com.zjb.accountManager.Kits.AuthKit;
import com.zjb.accountManager.beans.model.User;

public class CpCommon extends Controller {
	
	public void index() {
		this.renderError(404);
	}

	public void login() {
		String account = this.getPara("account");
		String password = this.getPara("password");
		User user = User.dao.findLoginedAccount(account, password);
		
		if (user == null) {
			this.renderJson(false);
			return;
		}
		
		AuthKit.setAuthorize(this, user.getId(), user.getAccount());
		this.renderJson(true);
	}
	
	public void logout() {
		AuthKit.clearAuthorize(this);
		this.renderJson(true);
	}
}
